repo.or.cz
/
andmenj-acm.git
/
blob
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
log
|
graphiclog1
|
graphiclog2
|
commit
|
commitdiff
|
tree
|
refs
|
edit
|
fork
blame
|
history
|
raw
|
HEAD
Namespacing everything to /UVa.
[andmenj-acm.git]
/
UVa
/
993 - Product of digits
/
993.cpp
blob
5bab61733fa9a570f78086affff0c1fb009b1acf
1
/*
2
Problem: 993 - Product of digits
3
Author: Andrés Mejía-Posada
4
(http://blogaritmo.factorcomun.org)
5
6
*/
7
8
using namespace
std
;
9
#include <algorithm>
10
#include <iostream>
11
#include <iterator>
12
#include <sstream>
13
#include <fstream>
14
#include <cassert>
15
#include <climits>
16
#include <cstdlib>
17
#include <cstring>
18
#include <string>
19
#include <cstdio>
20
#include <vector>
21
#include <cmath>
22
#include <queue>
23
#include <deque>
24
#include <stack>
25
#include <map>
26
#include <set>
27
28
#define D(x) cout << #x
" is "
<< x << endl
29
30
int
main
(){
31
int
c
;
32
for
(
cin
>>
c
;
c
--; ){
33
int
n
;
34
cin
>>
n
;
35
36
if
(
n
==
1
){
37
cout
<<
1
<<
endl
;
38
continue
;
39
}
40
41
string ans
=
""
;
42
for
(
int
i
=
9
;
i
>=
2
; --
i
){
43
while
(
n
%
i
==
0
){
44
n
/=
i
;
45
ans
=
char
(
i
+
'0'
) +
ans
;
46
}
47
}
48
49
if
(
n
>
1
){
50
ans
=
"-1"
;
51
}
52
53
cout
<<
ans
<<
endl
;
54
}
55
return
0
;
56
}